package net.ds0101.FindTen;

import com.baidu.AdType;
import com.baidu.AdView;
import com.mobclick.android.MobclickAgent;

import android.os.Bundle;
import android.view.Gravity;
import android.widget.FrameLayout;
import net.ds0101.framework.android.neox.main.NXDirector;
import net.ds0101.framework.android.neox.main.NXScene;

public class MainEntry extends NXDirector {
	private NXScene mStartLogo;
	private int mRow, mCol;
	private FrameLayout.LayoutParams mLayoutParams;
	private AdView mAdsView;
	
	@Override
	public int onMain() {
		NXScene.fpsDisplay(false);
		mStartLogo = new LogoScene(this);
		replaceWithScene(mStartLogo);
		
		addAdsViewBottom();
		return 0;
	}
	
	/*public void addAdsViewTop() {
		View adsView = new AdView(this, Color.GRAY, Color.WHITE, 100);
		
		if (null == mLayoutParams) {
			mLayoutParams = new
			FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
					FrameLayout.LayoutParams.WRAP_CONTENT);
			mLayoutParams.topMargin = 0;
			mLayoutParams.gravity = Gravity.TOP;
		}
		addContentView(adsView, mLayoutParams);
	}*/
	
	public void addAdsViewBottom() {
		//View adsView = new AdView(this, Color.GRAY, Color.WHITE, 100);
		if (null == mAdsView) mAdsView = new AdView(this, AdType.IMAGE);
		if (null == mLayoutParams) {
			mLayoutParams = new
			FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
					FrameLayout.LayoutParams.WRAP_CONTENT);
			mLayoutParams.bottomMargin = 0;
			mLayoutParams.gravity = Gravity.BOTTOM;
		}
		addContentView(mAdsView, mLayoutParams);
	}
	
	public int gameGridRow() {
		return mRow;
	}
	
	public int gameGridCol() {
		return mCol;
	}
	
	public void gameGrid(int row, int col) {
		mRow = row;
		mCol = col;
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    //MobclickAgent.onError(this);
	    MobclickAgent.update(this);
	}
	
	@Override
	public void onResume() {
		super.onResume();
		MobclickAgent.onResume(this);
	}
	
	@Override
	public void onPause() {
		super.onPause();
		MobclickAgent.onPause(this);
	}
}
